using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Main;

namespace AtletIS.Database.Mapping.Main
{
    public class ChipTagMap : EntityTypeConfiguration<ChipTag>
    {
        public ChipTagMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ChipTagsGroupId, t.ChipTag1 });

            // Properties
            this.Property(t => t.ChipTagsGroupId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ChipTag1)
                .IsRequired()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("ChipTags");
            this.Property(t => t.ChipTagsGroupId).HasColumnName("ChipTagsGroupId");
            this.Property(t => t.ChipTag1).HasColumnName("ChipTag");
            this.Property(t => t.StartNumber).HasColumnName("StartNumber");
            this.Property(t => t.Sync).HasColumnName("Sync");
            this.Property(t => t.Modified).HasColumnName("Modified");

            // Relationships
            this.HasRequired(t => t.ChipTagsGroup)
                .WithMany(t => t.ChipTags)
                .HasForeignKey(d => d.ChipTagsGroupId);

        }
    }
}
